#!/bin/sh

pid_file='/dev/shm/ssh-link.pid'

all_pid=`ps axc`

echo "$all_pid" | grep `cat $pid_file`

retcode=$?

if [ $retcode -eq 0 ]  ;  then
        echo "ssh already running"
        exit
fi

nohup ssh -N -o ServerAliveCountMax=6 -o ServerAliveInterval=30 -R 5908:localhost:5901 ubuntu@3.3.2.98  >/dev/null 2>&1 &

ssh_pid="$!"

echo "$ssh_pid" > $pid_file

echo "exec $ssh_pid ok"

